﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports <xmlns="http://kadgen.com/tempCode">


Public Class AttributeInfo

   Private mName As String
   'Private mStandardAttributes As StandardAttributes
   Private mParameters As IEnumerable(Of String)

   Public Sub New()
   End Sub

   Public Sub New(ByVal name As String, ByVal ParamArray parameters() As String)
      mName = name
      mParameters = parameters
   End Sub

   'Public Sub New(ByVal standardAttributes As StandardAttributes, ByVal ParamArray parameters() As String)
   '   mStandardAttributes = standardAttributes
   '   mParameters = parameters
   'End Sub

   Public Property Name() As String
      Get
         Return mName
      End Get
      Set(ByVal value As String)
         mName = value
      End Set
   End Property


   Public Property Parameters() As IEnumerable(Of String)
      Get
         Return mParameters
      End Get
      Set(ByVal value As IEnumerable(Of String))
         mParameters = value
      End Set
   End Property

   'Public Property StandardAttributes() As StandardAttributes
   '   Get
   '      Return mStandardAttributes
   '   End Get
   '   Set(ByVal value As StandardAttributes)
   '      mStandardAttributes = value
   '   End Set
   'End Property



End Class

Public Class AttributeInfoCollection
   Inherits List(Of AttributeInfo)

   'Private mStandardAttributes As StandardAttributes

   'Public Property StandardAttributes() As StandardAttributes
   '   Get
   '      Return mStandardAttributes
   '   End Get
   '   Set(ByVal value As StandardAttributes)
   '      mStandardAttributes = value
   '   End Set
   'End Property

   'Public Overloads Sub Add(ByVal attributes As StandardAttributes)
   '   mStandardAttributes = mStandardAttributes Or attributes
   'End Sub

   Public Overloads Function Add(ByVal attributeName As String, ByVal ParamArray parameters() As String) As AttributeInfo
      Dim newInfo As New AttributeInfo(attributeName, parameters)
      Me.Add(newInfo)
      Return newInfo
   End Function

   Public Function AddSerializable() As AttributeInfo
      Return Me.Add("System.Serializable")
   End Function

   Public Function AddDataObject() As AttributeInfo
      Return Me.Add("System.ComponentModel.DataObject", Strings.trueString, Strings.trueString)
   End Function

   Public Function AddNoInlining() As AttributeInfo
      Return Me.Add("System.Runtime.CompilerServices.MethodImpl", _
                    "System.Runtime.CompilerServices.MethodImplOptions.NoInlining")
   End Function

   '      Serializable = 1
   '   DataObject = 2
   '   NoInlining = 4

   '            If attributes.Contains(StandardAttributes.Serializable) Then
   '            ret &= _
   '   <code>&lt;<%= StandardAttributes.Serializable.ToString() %>()> _</code>.Value
   '         End If
   '         If attributes.Contains(StandardAttributes.NoInlining) Then
   '            ret &= _
   '<code>
   '      &lt;System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)> _</code>.Value
   '         End If


End Class

Namespace VB
   Public Module AttributeInfoExtensions
      <System.Runtime.CompilerServices.Extension()> _
      Public Function Output(ByVal attributes As AttributeInfoCollection) As String
         If attributes IsNot Nothing Then
            Dim ret = String.Empty
            For Each AttributeInfo In attributes
               ret &= <code>
            &lt;<%= AttributeInfo.Name %>> _</code>.Value
            Next
            Return ret
         End If
         Return Nothing
      End Function
   End Module
End Namespace

Namespace CSharp
   Public Module AttributeInfoExtensions
      <System.Runtime.CompilerServices.Extension()> _
      Public Function Output(ByVal attributes As AttributeInfoCollection) As String
         If attributes IsNot Nothing Then
            Dim ret = String.Empty
            For Each AttributeInfo In attributes
               ret &= <code>
            [<%= AttributeInfo.Name %>] </code>.Value
            Next
            Return ret
         End If
         Return Nothing
      End Function
   End Module
End Namespace
